package com.xxxx.web.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xxxx.web.dto.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;

/**
 * 盘点单表表
 */
@Data
@TableName("`InventoryCheck`")
public class InventoryCheck extends BaseEntity {


    /**
     * 是否执行库存调整
     */
    @JsonProperty("IsExcuteInventoryChange")
    @TableField(value = "IsExcuteInventoryChange", updateStrategy = FieldStrategy.IGNORED)
    private Boolean IsExcuteInventoryChange;

    /**
     * 盘点人
     */
    @JsonProperty("CheckUserId")
    @TableField(value = "CheckUserId", updateStrategy = FieldStrategy.IGNORED)
    private Integer CheckUserId;

    /**
     * 货主
     */
    @JsonProperty("CustomerId")
    @TableField(value = "CustomerId", updateStrategy = FieldStrategy.IGNORED)
    private Integer CustomerId;

    /**
     * 单号
     */
    @JsonProperty("No")
    @TableField(value = "No", updateStrategy = FieldStrategy.IGNORED)
    private String No;

    /**
     * 起始盘点时间
     */
    @JsonProperty("BeginCheckTime")
    @TableField(value = "BeginCheckTime", updateStrategy = FieldStrategy.IGNORED)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime BeginCheckTime;

    /**
     * 仓库
     */
    @JsonProperty("WarehouseId")
    @TableField(value = "WarehouseId", updateStrategy = FieldStrategy.IGNORED)
    private Integer WarehouseId;

    /**
     * 盘点状态
     */
    @JsonProperty("InventoryCheckStatus")
    @TableField(value = "InventoryCheckStatus", updateStrategy = FieldStrategy.IGNORED)
    private Integer InventoryCheckStatus;

    /**
     * 截至盘点时间
     */
    @JsonProperty("EndCheckTime")
    @TableField(value = "EndCheckTime", updateStrategy = FieldStrategy.IGNORED)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime EndCheckTime;

    /**
     * 把盘点单表实体转换成盘点单表传输模型
     */
    public InventoryCheckDto MapToDto() throws InvocationTargetException, IllegalAccessException {
        InventoryCheckDto InventoryCheckDto = new InventoryCheckDto();

        BeanUtils.copyProperties(InventoryCheckDto, this);

        return InventoryCheckDto;
    }

}
